<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" th:src="@{/js/jquery.js}"></script>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li>营销管理</li>
        <li>客户管理</li>
        <li>添加</li>
    </ul>
</div>
<form method="post" action="/erp1/market/customer/addCustom" class="formbody">
    <div class="formtitle"><span>客户信息</span></div>
    <ul class="forminfo">
        <li>
            <label>姓名</label>
            <input name="customname" type="text" class="dfinput"/>
            <i>必填，不能超过30个字符</i>
        </li>
        <li>
            <label>性别</label>
            <cite>
                <input name="sex" type="radio" value="2" checked="checked"/>男
                &nbsp;&nbsp;&nbsp;&nbsp;
                <input name="sex" type="radio" value="1"/>女
            </cite>
        </li>
        <li>
            <label>所属公司名称</label>
            <input name="company" type="text" class="dfinput"/>
            <i>必填，不能超过30个字符</i>
        </li>
        <li>
            <label>联系方式</label>
            <input name="telephone" type="text" class="dfinput"/>
            <i>必填，不能超过30个字符</i>
        </li>
        <li>
            <label>联系地址</label>
            <input name="homeaddress" type="text" class="dfinput"/>
            <i>必填，不能超过130个字符</i>
        </li>
        <li>
            <label>所属区域</label>
            <select name="customPid" class="dfselect" onchange="getCity(this.value)">
                <option value="0">请选择省份</option>
                <option th:each="p:${session.provinces}" th:text="${p.pName}" th:value="${p.id}"></option>
            </select>
            省
            <select name="address" class="dfselect">
                <option value="0">请选择</option>
            </select>
            市
            <i>必选</i>
        </li>
        <script>
            function getCity(num) {
                //异步请求
                $.get("/erp1/ajaxCity", {"pid": num}, function (data) {
                    // JSON.parse(data);  data--->object
                    //清空内容
                    console.log(data);
                    $("select[name=address]").html("");
                    var options = "<option value=''>请选择城市</option>";
                    $.each(data, function (i, e) {
                        options += "<option value='" + e.id + "'>" + e.cname + "</option>";
                    });
                    $("select[name=address]").append(options);
                }, "json");
            }
        </script>
        <li>
            <label>描述</label>
            <textarea class="textinput" name="distract"></textarea>
            <i>可选</i>
        </li>
        <li>
            <label>状态</label>
            <select class="dfselect" name="status">
                <option value="1">可用</option>
                <option value="0">不可用</option>
            </select>
            <i>必选</i>
        </li>
        <li>
            <label>创建人</label>
            <input name="createid" type="hidden" th:value="${session.currUser.uId}">
            <input type="text" th:value="${session.currUser.uname}" readonly="readonly" class="roinput"/>
            <i>不能编辑</i>
        </li>
        <li>
            <label>客服人员</label>
            <input type="text" name="serviceid" th:value="10" readonly="readonly" class="roinput"/>
        </li>
        <li>
            <label>创建时间</label>
            <input name="createtime" type="text" th:value="${#dates.format(#dates.createToday(),'yyyy-MM-dd hh:MM:ss')}" readonly="readonly" class="roinput"/>
            <i>不能编辑</i>
        </li>

        <li>
            <label>&nbsp;</label>
            <input name="" type="submit" class="btn" value="确定"/>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="" type="button" class="btn" value="返回"
                   onclick="window.history.go(-1);"/>
        </li>
    </ul>
</form>
</body>
</html>